﻿<cfmodule template="../../tag/layout.cfm" bodyIsEasyUILayout="false">
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script>
<form method="post" class="form" name="form">
<input  type="hidden" name="equipmenttype" value="<cfoutput>#rc.equipmenttype#</cfoutput>">
  <fieldset>
    <legend>基本信息</legend>
    <table class="table" width="100%">
      <tbody>
        <tr>
          <th>编号</th>
          <td><input name="id" readonly /></td>
          <th>产品编码</th>
          <td><input name="procode" class="easyui-validatebox" data-options="required:true"/></td>
        </tr>
        <tr>
          <th>产品名称</th>
          <td><input name="prochsname" class="easyui-validatebox" data-options="required:true"/></td>
          <th>通用名称</th>
          <td><input name="proussname"/></td>
        </tr>
		<tr>
			<th>英文名称<br/>自动转换</th>
			<td colspan="3"><input name="proenname" style="width:600px;"/></td>
        </tr>
        <tr>
          <th>拼音全码<br/>自动转换</th>
          <td><input name="propyfullspell"/></td>
          <th>拼音简码<br/>自动转换</th>
          <td><input name="propysimplespell" /></td>
        </tr>
        <tr>
          <th>产品简介</th>
          <td colspan="3"><input type="text" name="brief" style="width:600px;"></td>
        </tr>
        <tr>
        	<th>默认图片</th>
			<td>
				<select class="selectFiles"><option>选择文件</option></select>
	          	<a href="#" class="easyui-linkbutton uploader" data-options="iconCls:'icon-add'">选择文件</a>
	          	<input name="picdefault" id="picdefault" class="selectFilesValue" type="hidden" />
			</td>
			<th>产品图集</th>
			<td>
				<select class="selectFiles"><option>选择文件</option></select>
	          	<a href="#" class="easyui-linkbutton uploader" data-options="iconCls:'icon-add'">选择文件</a>
	          	<input name="pics" id="pics" class="selectFilesValue" type="hidden" />
			</td>
        </tr>
        <tr>
        	<th>gmp证书</th>
			<td>
				<select class="selectFiles"><option>选择文件</option></select>
	          	<a href="#" class="easyui-linkbutton uploader" data-options="iconCls:'icon-add'">选择文件</a>
	          	<input name="gmp" id="gmp" class="selectFilesValue" type="hidden" />
			</td>
			<th>注册文件</th>
			<td>
				<select class="selectFiles"><option>选择文件</option></select>
	          	<a href="#" class="easyui-linkbutton uploader" data-options="iconCls:'icon-add'">选择文件</a>
	          	<input name="registerfile" id="registerfile" class="selectFilesValue" type="hidden" />
			</td>
        </tr>

        <tr>
        	<th>质检单据</th>
			<td colspan="3">
				<select class="selectFiles"><option>选择文件</option></select>
	          	<a href="#" class="easyui-linkbutton uploader" data-options="iconCls:'icon-add'">选择文件</a>
	          	<input name="qualification" id="qualification" class="selectFilesValue" type="hidden" />
			</td>
        </tr>


        <tr>
          <th>选择产品<br/>供应商</th>
          <td>
          	<input type="hidden" id="supplierid" name="supplierid">
          	<input type="text" id="suppliername" name="suppliername" readonly="readonly"  class="easyui-validatebox" data-options="required:true">
          	<a href="#" onclick="selectSupplier()">选择产品供应商</a>
          </td>
          <th>选择产品<br/>所属类别</th>
          <td>
          	<input type="hidden" id="categoryids" name="categoryids">
          	<input type="text" id="categorynames" name="categorynames" readonly="readonly"  class="easyui-validatebox" data-options="required:true">
          	<a href="#" onclick="selectCategorys()">选择产品所属类别</a>
          </td>
        </tr>

		<tr>
          <th>产品规格</th>
          <td><input name="specification" class="easyui-validatebox" data-options="required:true"/></td>
          <th>批准文号</th>
          <td><input name="approvalnumber" class="easyui-validatebox" data-options="required:true"/></td>
        </tr>

        <tr>
          <th>生产厂家</th>
          <td><input name="producingname" class="easyui-validatebox" data-options="required:true"/></td>
          <th>生产产地</th>
          <td><input name="producingarea" /></td>
        </tr>

        <tr>
          <cfif equipmenttype eq 0>
	          <th>包装单位</th>
	          <td><input name="packingunit" class="easyui-validatebox" data-options="required:true"/></td>
	          <th>产品剂型</th>
	          <td><input name="dosageform" /></td>
          <cfelse>
	          <th>包装单位</th>
	          <td colspan="3"><input name="packingunit" class="easyui-validatebox" data-options="required:true"/></td>
          </cfif>
        </tr>

		<tr>
          <th>市场价格</th>
          <td><input name="marketprice" class="easyui-numberbox" precision="2"  data-options="required:true"/></td>
          <th>销售价格</th>
          <td><input name="saleprice" class="easyui-numberbox" precision="2"  data-options="required:true"/></td>
        </tr>

		<tr>
			<cfif equipmenttype eq 0>
          <th>医保类型</th>
          <td>
          	<input type="radio" name="medicaltype" value="0" class="easyui-validatebox" validType="radio['form','medicaltype']"> 甲类
          	<input type="radio" name="medicaltype" value="1" class="easyui-validatebox" validType="radio['form','medicaltype']"> 乙类
          	<input type="radio" name="medicaltype" value="2" class="easyui-validatebox" validType="radio['form','medicaltype']"> 非医保
          </td>
          <th>处方类型</th>
          <td>
          	<input type="radio" name="otctype" value="0" class="easyui-validatebox" validType="radio['form','otctype']"> 非处方药
          	<input type="radio" name="otctype" value="1" class="easyui-validatebox" validType="radio['form','otctype']"> 处方药
          	<input type="radio" name="otctype" value="2" class="easyui-validatebox" validType="radio['form','otctype']"> 医疗器械
          	<input type="radio" name="otctype" value="3" class="easyui-validatebox" validType="radio['form','otctype']"> 其它
          </td>
          <cfelse>
			<th>医保类型</th>
	          <td colspan="3">
	          	<input type="radio" name="medicaretype" value="0" class="easyui-validatebox" validType="radio['form','medicaretype']"> 甲类
	          	<input type="radio" name="medicaretype" value="1" class="easyui-validatebox" validType="radio['form','medicaretype']"> 乙类
	          	<input type="radio" name="medicaretype" value="2" class="easyui-validatebox" validType="radio['form','medicaretype']"> 非医保
	          </td>
		  </cfif>
        </tr>

        <tr>
          <th>库存数量</th>
          <td><input type="text" name="inventory" class="easyui-numberspinner" value="-1" style="width:60px;"> (注:-1为无限制库存)</td>
          <th>商品购买<br/>数量限制</th>
          <td><input type="text" name="buynumlimit" class="easyui-numberspinner" value="-1" style="width:60px;"> (注:-1为无限制数量)</td>
        </tr>

        <tr>

        <th>关键词</th>
          <td colspan="3"><input type="text" name="keywords" style="width:600px;"></td>
        </tr>

		<tr>
          <th>产品介绍</th>
          <td colspan="3">
          	<textarea id="content" name="content" style="width:600px; height:120px;"></textarea>
          	<input type='button' mode='0' class='editor' onclick="EditorRender('content',$(this))" value='切换至编辑器'>
          </td>
        </tr>
		<tr>
          <th>点击数量</th>
          <td><input type="text" name="hits" class="easyui-numberspinner" value="0" style="width:60px;"></td>
          <th>排序值</th>
          <td><input type="text" name="seq" class="easyui-numberspinner" value="0" style="width:60px;"> </td>
        </tr>
        <tr>
          <th>产品属性</th>
          <td colspan="3">
			<input type="checkbox" name="isindex" value="1"> 是否首页
			<input type="checkbox" name="iscommend" value="1"> 是否推荐
			<input type="checkbox" name="istop" value="1"> 是否置顶
			<input type="checkbox" name="isscroll" value="1"> 是否滚动
			<input type="checkbox" name="ishot" value="1"> 是否热销
			<br/>
			<input type="checkbox" name="isspecial" value="1"> 是否特色
			<input type="checkbox" name="ischannell" value="1"> 频道主打
			<input type="checkbox" name="isnew" value="1"> 是否新品
			<input type="checkbox" name="iscomment" value="1"> 是否评论
          </td>
        </tr>
      </tbody>
    </table>
  </fieldset>
</form>

</cfmodule>
<cfscript>
	if( structKeyExists(rc, "id")  && rc.id > 0 ){
		id = rc.id;
	}else{
		id = 0;
	}
</cfscript>

<script type="text/javascript">
	function selectSupplier(){
		var supplierid = $('#supplierid');
		var suppliername = $('#suppliername');
		var dialog = parent.fw.modalDialog({
	        title: '选择供应商',
	        width:800,
	        height:600,
	        url: '?action=product.supplier',
	        buttons: [
	        {
	            text: '选择供应商',
	            handler: function() {
	                dialog.find('iframe').get(0).contentWindow.submitForm(dialog,supplierid,suppliername);
	            }
	        },{
	            text: '关闭窗口',
	            handler: function() {
	               dialog.find('iframe').get(0).contentWindow.closeDialog(dialog);
	            }
	        }]
	    });
	}

	function selectCategorys(){
		var categoryids = $('#categoryids');
		var categorynames = $('#categorynames');
		if(categoryids.val().length>0){
			var url = "?action=product.categorys&selectedids=" +categoryids.val();
		}else{
			var url = "?action=product.categorys";
		}
		var dialog = parent.fw.modalDialog({
	        title: '选择产品类别',
	        width:800,
	        height:600,
	        url: url,
	        buttons: [
	        {
	            text: '选择产品类别',
	            handler: function() {
	                dialog.find('iframe').get(0).contentWindow.submitForm(dialog,categoryids,categorynames);
	            }
	        },{
	            text: '关闭窗口',
	            handler: function() {
	               dialog.find('iframe').get(0).contentWindow.closeDialog(dialog);
	            }
	        }]
	    });
	}


	var closeDialog = function($dialog) {
		$dialog.dialog('destroy');
	}

	var submitNow = function($dialog, $grid, $pjq) {
		var url;
		if ($(':input[name="id"]').val().length > 0) {
			url = '?action=product.update'; //更新操作
		} else {
			url = '?action=product.save';	//新增操作
		}

//		console.log(fw.serializeObject($('form')));
		$.post(url, fw.serializeObject($('form')), function(result) {
			if (result) {
				$grid.datagrid('reload');
				$dialog.dialog('destroy');
			}
		}, 'json');
	};

	var submitForm = function($dialog, $grid, $pjq) {
		if ($('form').form('validate')) {
			submitNow($dialog, $grid, $pjq);
		}
	};

	//加载数据，初始进度条
	parent.$.messager.progress({
		text : '数据加载中....'
	});

	$(function(){
		$(".uploader").on('click',uploaderFun);


		<cfif id gt 0>
		$.ajax({
		    type: "POST",
		    url: "?action=product.get",
		    data: {
		        id:<cfoutput>#id#</cfoutput>
		    }
		}).done(function(result) {
			$('form').form('load', result);

			//picdefaultname
			if(result.picdefaultname.length>0){
				var pdoptions = "<option>选择文件( 选中了 1 个 )</option>";
				pdoptions +="<option>" + result.picdefaultname + "</option>";
				$('#picdefault').prev().prev('.selectFiles').html(pdoptions);
			}

			//pics
			if(result.picsname.length>0){
				var picsoptions = "<option>选择文件( 选中了 "+result.picsname.length+" 个 )</option>";
				for(var i=0;i<result.picsname.length;i++){
					picsoptions +="<option>" + result.picsname[i] + "</option>";
				}
				$('#pics').prev().prev('.selectFiles').html(picsoptions);
			}

			//gmpname
			if(result.gmpname.length>0){
				var gmpoptions = "<option>选择文件( 选中了 1 个 )</option>";
				gmpoptions +="<option>" + result.gmpname + "</option>";
				$('#gmp').prev().prev('.selectFiles').html(gmpoptions);
			}


			//registerfilename
			if(result.registerfilename.length>0){
				var rgoptions = "<option>选择文件( 选中了 1 个 )</option>";
				rgoptions +="<option>" + result.registerfilename + "</option>";
				$('#registerfile').prev().prev('.selectFiles').html(rgoptions);
			}


			//qualificationname
			if(result.qualificationname.length>0){
				var qfoptions = "<option>选择文件( 选中了 "+result.qualificationname.length+" 个 )</option>";
				for(var i=0;i<result.qualificationname.length;i++){
					qfoptions +="<option>" + result.qualificationname[i] + "</option>";
				}
				$('#qualification').prev().prev('.selectFiles').html(qfoptions);
			}


			parent.$.messager.progress('close');
		}, 'json');

		<cfelse>
			parent.$.messager.progress('close');
		</cfif>
	})
</script>
